﻿namespace Complaint.Models.Dtos.JavascriptConverters
{
    /// <summary>
    /// Represents an interface that implementing types can use to serialize/deserialize themselves to/from Json strings.
    /// </summary>
    /// <typeparam name="T">The type of the implementing class.</typeparam>
    public interface IJsonConverter<T>
    {
        /// <summary>
        /// Serializes the current instance of the object into a Json formatted string.
        /// </summary>
        /// <returns>A Json representation of the current instance.</returns>
        string ToJson();

        /// <summary>
        /// Creates a new instance of the current type from the passed Json string.
        /// </summary>
        /// <param name="json">The Json string representing the serialized instance.</param>
        /// <returns>A new instance of the current type.</returns>
        T FromJson(string json);
    }
}
